<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2023-01-09 16:16:23
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-01-09 17:04:53
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./baidu.js"></script>
</head>
<body>
    <script>
        var mydata = JSON.parse(alldata);
        // console.log(typeof mydata);
        //console.log(mydata['cardData']['cards454146550'].length);
        
        var province = mydata['cardData']['cards454146550'][0]['data']['sourceFilter']['list']; // 省的
        var city = mydata['cardData']['cards454146550'][1]['data']['listData']['list']; //各个城市的数据
        // var res = city.filter(function(item){
        //     return item['province'] == '山东';
        // });
        // console.log(res);
        var mysearch = prompt('请输入要查询的省份');
        var res = city.filter(function(item){
            return item['province'] == mysearch;
        });
        console.log(res);

        var resdata = [];
        res.forEach(function(item){
            var obj = {};
            obj['chengshi'] = item['city'];
            obj['sousuofengzhi'] = item['firstPeak'];
            obj['gaofengjieshu'] = item['firstResult'];
            obj['fengzhijindu'] = item['peakRate']+'%';
            obj['kaishishijian'] = item['startTime'];
            resdata.push(obj);
        });
       console.log(resdata);
    </script>
</body>
</html>